const Mock = require("mockjs")

const data = Mock.mock({
    "list|10-15": [
        {
            img: "@image(100x150,@color)",
            title: "@ctitle(10,15)",
            "money|1-1000": 1,
            id: "@id",
            "imger|5": [
                {
                    img: "@image(100x150,@color)"
                }
            ],3 2f
            someTitle: "@ctitle(20,30)"
        }
    ]
});


Mock.mock("/api/getlist", 'post', () => {
    return {
        code: 200,
        data: data.list
    }
})


Mock.mock('/api/getdetail', 'post', (req) => {
    // // 解构出来请求的id
    // const { id } = JSON.parse(req.body)
    const id = req.body
    // // 筛选数据
    // console.log(id);
    const item = data.list.find(item => item.id === id)
    // console.log(data.list);

    return {
        code: 200,
        data: item
    }
})